#include "Block.h"
#include "GameMap.h"
#include "define.h"

// 构造函数
Block::Block()
{
	// 加载图片
	loadimage(&imgWall, "./resources/image/wall.gif");
	loadimage(&imgIron, "./resources/image/iron.gif");
	loadimage(&imgHome, "./resources/image/home.jpg");

	// 得到当前地图
	map = GameMap::getMap();
}

// 绘制方块
void Block::draw()
{
	// 绘制墙块与铁块
	for (int i = 0; i < 26; i++)
	{
		for (int j = 0; j < 26; j++)
		{
			int value = map[i][j];
			if (value > 0)
			{
				if (value == WALL)			// 墙块
				{
					putimage(j * BLOCK_SIZE, i * BLOCK_SIZE, &imgWall);
				}
				else if (value == IRON)	// 铁块
				{
					putimage(j * BLOCK_SIZE, i * BLOCK_SIZE, &imgIron);
				}
			}
		}
	}

	// 绘制老巢
	myDrawImage(12 * BLOCK_SIZE, 24 * BLOCK_SIZE, &imgHome);
}